<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>

	<script>  
         $('input:not([type="button"]),select,textarea').live('keydown', function(e) {      
                var nodeName = e.target.nodeName.toLowerCase();      
                if (e.which === 13) {      
                    if (nodeName === 'input' &amp;&amp; e.target.type != 'button' &amp;&amp; e.target.type != 'submit' ||      
                        nodeName === 'select' || nodeName === 'textarea') {      
                        var focusable = $('input,a,select,button,textarea').filter(':visible');      
                        focusable.eq(focusable.index(this)+1).focus();      
                        return false;      
                    }      
                }      
            });      
        </script>
</h:head>
<h:body>
	<h:form>
		<p:panel id="panel" header="Cadastro de Clientes">

			<p:messages id="mensagens" showDetail="False" autoUpdate="true"
				closable="true" />
			<p:focus context="panel" />

			<h:inputHidden value="#{clienteBean.clienteSelecionado.id}" />
			
			<p:commandButton value="Novo" update="@form"
				action="#{clienteBean.novo}" />

			<p:commandButton value="Salvar" update="@form"
				action="#{clienteBean.salvar}" />
				
				

			<p:commandButton value="Sair" action="paginaInicialFinanceiro.jsf" />

           <br/>
           <br/>

			<p:panelGrid columns="6">
				<h:outputLabel value="Nome" />
				<p:inputText id="nomeCliente"
					value="#{clienteBean.clienteSelecionado.nome}" required="false" />

				<h:outputLabel value="CPF/CNPJ" />
				<p:inputText value="#{clienteBean.clienteSelecionado.cpf}"/>
					

				

				<h:outputLabel value="Endereço" />
				<p:inputText value="#{clienteBean.clienteSelecionado.endereco}" />

				<h:outputLabel value="E-mail" />
				<p:inputText value="#{clienteBean.clienteSelecionado.email}" />

				<h:outputLabel value="Limite" />
				<p:inputText value="#{clienteBean.clienteSelecionado.renda}">
					<f:convertNumber minFractionDigits="2" />
								
				</p:inputText>
					
				<h:outputLabel value="Data Cadastro" />
				    <p:calendar value="#{clienteBean.clienteSelecionado.dataCadastro}" id="popupCal" >
					<f:convertDateTime dateStyle="medium" />
                 </p:calendar>  
			
			</p:panelGrid>

			<br />      
				
			
			

			<p:dataTable value="#{clienteBean.lista}" var="cliente" border="1"
				rendered="#{not empty clienteBean.lista}">


				<p:column>
					<f:facet name="header">Nome</f:facet>
				#{cliente.nome}
				</p:column>

				<p:column>
					<f:facet name="header">CPF</f:facet>
				#{cliente.cpf}
				</p:column>

				<p:column>
					<f:facet name="header">Dt. Cadastro</f:facet>

					<h:outputText value="#{cliente.dataCadastro}">
						<f:convertDateTime dateStyle="medium" />

					</h:outputText>
				</p:column>

				<p:column>
					<f:facet name="header">E-mail</f:facet>
				#{cliente.email}
				</p:column>

				<p:column>
					<f:facet name="header">Endereço</f:facet>
				#{cliente.endereco}
				</p:column>

				<p:column>
					<f:facet name="header">Renda</f:facet>
					<h:outputText value="#{cliente.renda}">
						<f:convertNumber currencyCode="BRL" type="currency" />
					</h:outputText>

				</p:column>

				<p:column>
					<f:facet name="header">Ações</f:facet>
					<h:commandLink action="#{clienteBean.excluir}"
						onclick="if(!confirm('Deseja realmente excluir o cliente #{cliente.nome}?.')) return false;">
						<h:graphicImage library="imagens" name="Deletar24x24.png" />
						<f:setPropertyActionListener
							target="#{clienteBean.clienteSelecionado}" value="#{cliente}" />


					</h:commandLink>

					<h:commandLink>
						<h:graphicImage library="imagens" name="Update32x32.png" />
						<f:setPropertyActionListener
							target="#{clienteBean.clienteSelecionado}" value="#{cliente}" />


					</h:commandLink>


				</p:column>

			</p:dataTable>
			<br/>
			<br/>
			 
			
			<p:dock>
				<p:menuitem value="Salvar" url="http://www.google.com.br"
					icon="resources/imagens/home.png" />
				<p:menuitem value="Alterar" url="#"
					icon="resources/imagens/financeiro.png" />
				<p:menuitem value="Excluir" url="#"
					icon="resources/imagens/clientes.png" />
				<p:menuitem value="Pesquisar" url="#"
					icon="resources/imagens/produtos.png" />
				<p:menuitem value="Sair" url="paginaInicialFinanceiro.jsf"
					icon="resources/imagens/backups.png" />
			</p:dock>


		</p:panel>
	</h:form>
</h:body>
</html>
